TSAN error for send_node_id_handshake test #2060
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When running Clang/TSAN I get the following:
https://gist.github.com/wezrule/279062783ed1ed2a2066ba5c79db0b83
What appears to happen is that the last
std::shared_ptr<nano::node>
reference gets released by analarm
operation which then calls the ~stat destructor. This modifies themap
(unprotected) and at the same time a packet is processed and astat
is trying to be incremented. I don't think this is the fault of stats rather the slightly random nature where the lastnode
shared_ptr reference is released which can cause problems in quite a few areas. But as this is the one that TSAN is warning about I have fixed it. Just adding astop
variable/function to prevent modifying stats when closing down the node. Have moved stats higher up the member list as most things have a dependency on it.